package h_10_12;

import java.util.ArrayList;
import java.util.LinkedList;
import java.util.List;
import java.util.Stack;

public class Main1 {
    public static int[][] fileCombination(int target) {
        // 返回的值的最大数不超过target 的一半
        int n = (target + 1) / 2;
        int sum = 0;
        List<int[]> list = new ArrayList<>();
        for(int left = 1,right = 1;right <= n;right++) {
            sum += right;
            if(sum > target) {
                sum -= left;
                left++;
                continue;
            }else if (sum == target){
                int[] arr = new int[right - left + 1];
                for(int k = left;k <= right;k++) {
                    arr[k - left] = k;
                }
                list.add(arr);
                continue;
            }
        }
        int[][] ret = new int[list.size()][];
        for(int i = 0;i < list.size();i++) {
            ret[i] = list.get(i);
        }
        return ret;
    }

    public static void main(String[] args) {
        int[][] ints = fileCombination(12);
        System.out.println(ints);
    }
}
